import java.util.*;

public class Solution819 {
    public String mostCommonWord(String paragraph, String[] banned) {
        paragraph=paragraph.replace("!"," ");
        paragraph=paragraph.replace("?"," ");
        paragraph=paragraph.replace("'"," ");
        paragraph=paragraph.replace(","," ");
        paragraph=paragraph.replace(";"," ");
        paragraph=paragraph.replace("."," ");
        String[] words=paragraph.toLowerCase().split(" ");
        int max=0;
        String ans="";
        Set<String> set = new HashSet<>(Arrays.asList(banned));
        Map<String,Integer> map=new HashMap<>();
        for (String word : words) {
            map.put(word,map.getOrDefault(word,0)+1);
            if (map.get(word)>max && !set.contains(word) && word.length()>0){
                max=map.get(word);
                ans=word;
            }
        }
        return ans;
    }

    public static void main(String[] args) {
        System.out.println(new Solution819().mostCommonWord("Bob hit a ball, the hit BALL flew far after it was hit.",new String[]{"hit"}));
    }
}
